#ifndef _LCD_CFG_H
#define _LCD_CFG_H
#include "mh2203.h"
#include "LCD_CTRL_LIB.h"

/*配置屏幕尺寸*/
#define LCD_WIDTH  240
#define LCD_HEIGHT 320

/*是否使用DMA*/
#define LCD_USE_DMA 1

/*屏幕IC选择*/
//#define LCD_ST7796
//#define LCD_GC9A91
#define LCD_ST7789S //LCD_ST7789兼容如果颜色反显修改这个为0x20


/*协议选择*/
#define LCD_SPI
//#define LCD_8080
//#define LCD_QSPI

#define SELECT_SPI3

#ifdef SELECT_SPI3
/*SPI选择*/
#define LCD_SPI_SELECT  SPI3

/*通用IO选择*/
#define LCD_CS_PORT GPIOA
#define LCD_CS_PIN  GPIO_Pin_15

#define LCD_RST_PORT GPIOB
#define LCD_RST_PIN  GPIO_Pin_7

#define LCD_BK_PORT  GPIOB
#define LCD_BK_PIN   GPIO_Pin_8

#define LCD_DC_PORT GPIOB                   //WR
#define LCD_DC_PIN  GPIO_Pin_6

/*SPI协议对应IO选择*/
#define LCD_SPI_MOSI_PORT GPIOB
#define LCD_SPI_MOSI_PIN  GPIO_Pin_5

#define LCD_SPI_MISO_PORT GPIOB
#define LCD_SPI_MISO_PIN  GPIO_Pin_4

#define LCD_SPI_CLK_PORT GPIOB
#define LCD_SPI_CLK_PIN  GPIO_Pin_3

#elif defined(SELECT_SPI2)

/*SPI选择*/
#define LCD_SPI_SELECT  SPI2

/*通用IO选择*/
#define LCD_CS_PORT GPIOC
#define LCD_CS_PIN  GPIO_Pin_13

#define LCD_RST_PORT GPIOC
#define LCD_RST_PIN  GPIO_Pin_14

#define LCD_BK_PORT  GPIOC
#define LCD_BK_PIN   GPIO_Pin_15

#define LCD_DC_PORT GPIOA
#define LCD_DC_PIN  GPIO_Pin_6

/*SPI协议对应IO选择*/
#define LCD_SPI_MOSI_PORT GPIOB
#define LCD_SPI_MOSI_PIN  GPIO_Pin_15

#define LCD_SPI_MISO_PORT GPIOB
#define LCD_SPI_MISO_PIN  GPIO_Pin_14

#define LCD_SPI_CLK_PORT GPIOB
#define LCD_SPI_CLK_PIN  GPIO_Pin_13

#else
/*SPI选择*/
#define LCD_SPI_SELECT  SPI1

/*通用IO选择*/
#define LCD_CS_PORT GPIOA
#define LCD_CS_PIN  GPIO_Pin_4

#define LCD_RST_PORT GPIOB
#define LCD_RST_PIN  GPIO_Pin_10

#define LCD_BK_PORT  GPIOC
#define LCD_BK_PIN   GPIO_Pin_15

#define LCD_DC_PORT GPIOB
#define LCD_DC_PIN  GPIO_Pin_2

/*SPI协议对应IO选择*/
#define LCD_SPI_MOSI_PORT GPIOA
#define LCD_SPI_MOSI_PIN  GPIO_Pin_7

#define LCD_SPI_MISO_PORT GPIOA
#define LCD_SPI_MISO_PIN  GPIO_Pin_6

#define LCD_SPI_CLK_PORT GPIOA
#define LCD_SPI_CLK_PIN  GPIO_Pin_5

#endif

/*QSPI协议对应IO选择*/
#define LCD_QSPI_D0_PORT
#define LCD_QSPI_D0_PIN
#define LCD_QSPI_D1_PORT
#define LCD_QSPI_D1_PIN
#define LCD_QSPI_D2_PORT
#define LCD_QSPI_D2_PIN
#define LCD_QSPI_D3_PORT
#define LCD_QSPI_D3_PIN
#define LCD_QSPI_CLK_PORT
#define LCD_QSPI_CLK_PIN

/*非用户使用宏*/
#define LCD_BK_H LCD_BK_PORT->BSRR|=LCD_BK_PIN;//背光点亮
#define LCD_BK_L LCD_BK_PORT->BRR|=LCD_BK_PIN;
#define LCD_RST_H LCD_RST_PORT->BSRR|=LCD_RST_PIN;//复位拉高
#define LCD_RST_L LCD_RST_PORT->BRR|=LCD_RST_PIN;
#define LCD_CS_H LCD_CS_PORT->BSRR|=LCD_CS_PIN;//片选拉高
#define LCD_CS_L LCD_CS_PORT->BRR|=LCD_CS_PIN;
#define LCD_DC_H LCD_DC_PORT->BSRR|=LCD_DC_PIN;//DC拉低代表命令
#define LCD_DC_L LCD_DC_PORT->BRR|=LCD_DC_PIN;//DC拉低代表命令

#endif
